package com.szholly.plug.form.upload;

import java.util.HashMap;
import java.util.LinkedHashMap;

import com.szholly.utils.util.StringUtils;
import com.szholly.data.general.IDomain;
import com.szholly.data.general.MemDomain;

/**
 * 文件类型
 */
public class FileTypeDic {
	private static HashMap<String, String> result;

	private static IDomain pDomain;

	public static String dic = "0";
	
	public static String picFile = "1";
	public static String excelFile = "2";
	public static String wordFile = "3";
	
	public static String pptFile = "4";
	public static String moveFile = "5";
	public static String zipFile = "6";
	
	public static String otherFile = "7";

	static {
		result = new LinkedHashMap<String, String>();
		result.put("0", "目录");
		result.put("1", "图片文件");
		result.put("2", "Excel文件");
		result.put("3", "Word文件");
		result.put("4", "PPT文件");
		result.put("5", "视频文件");
		result.put("6", "压缩文件");
		result.put("7", "其它文件");

		pDomain = new MemDomain(result, "(运维)附件类型");
	}

	public static IDomain getDomain() {
		return pDomain;
	}
	
	public static String getFileType(String fileExt){
		if(StringUtils.IsNullOrSpace(fileExt)){
			return otherFile;
		}
		fileExt = fileExt.trim().toLowerCase();
		switch (fileExt) {
			case "gif":
			case "jpg":
			case "jpeg":
			case "png":
			case "bmp":
				return picFile;
			case "xls":
			case "xlsx":
				return excelFile;
			case "doc":
			case "docx":
				return wordFile;
			case "ppt":
			case "pptx":
				return pptFile;
			case "swf":
			case "flv":
			case "mp3":
			case "wav":
			case "wma":
			case "wmv":
			case "mid":
			case "avi":
			case "mpg":
			case "asf":
			case "rm":
			case "rmvb":
				return moveFile;
			case "zip":
			case "rar":
			case "gz":
			case "bz2":
				return zipFile;
		}
		return otherFile;
	}
}
